package test02.a;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Author lzp
 * @Date 2024-03-19
 */
public class Test {
    public static void main(String[] args) throws InterruptedException, ExecutionException {
        SumThread01 sumThread01 = new SumThread01();
        SumThread02 sumThread02 = new SumThread02();
        SumThread03 sumThread03 = new SumThread03();

        FutureTask<Integer> c1 = new FutureTask<>(sumThread01);
        FutureTask<Integer> c2 = new FutureTask<>(sumThread02);
        FutureTask<Integer> c3 = new FutureTask<>(sumThread03);

        Thread t1 = new Thread(c1);
        Thread t2 = new Thread(c2);
        Thread t3 = new Thread(c3);

        t1.start();
        t2.start();
        t3.start();

        int sum = c1.get() + c2.get() + c3.get();
        System.out.println(sum);
    }
}
